package org.cl.tdd;

import java.util.HashMap;

public class ParkingPlace {

    private int maxSize;
    private HashMap<String, Car> parkCars = new HashMap<String, Car>();
    private String placeNo;

    public ParkingPlace(String placeNo, int maxSize) {
        this.placeNo = placeNo;
        this.maxSize = maxSize;
    }


    public boolean park(Car car) {
        if (parkCars.size() < maxSize) {
            parkCars.put(car.getCarNum(), car);
            return true;
        }
        return false;
    }


    public Car get(String carNum) {
        Car car = parkCars.get(carNum);
        if (car != null) {
            parkCars.remove(carNum);
        }
        return car;
    }

    public String getPlaceNo() {
        return placeNo;
    }

    public void setPlaceNo(String placeNo) {
        this.placeNo = placeNo;
    }

    public int getMaxSize() {
        return maxSize;
    }

    public void setMaxSize(int maxSize) {
        this.maxSize = maxSize;
    }

    public boolean isFull() {
        return parkCars.size() == maxSize;
    }

    public int getEmptyPlaceNum() {
        return maxSize - parkCars.size();
    }
}
